/*
 * OknoArchiwum.java
 *
 * Created on 24 maj 2009, 17:49
 */

package BasaSobol;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;

/**
 * 
 * @author  bąsa
 */
public class OknoArchiwum extends javax.swing.JFrame {
    public static boolean otwarte = false;

    /**
     * Funkcja wczytuje archiwum z pliku archiwum.txt
     */
    public void wczytaj() {
        FileReader fstream = null;
        BufferedReader br = null;
        try {
            fstream = new FileReader("archiwum.txt");
        } catch(Exception e) {
            
        }
        
        br = new BufferedReader(fstream);
        
        try {
            String s;
            while((s = br.readLine()) != null) {
                poleArchiwum.append(s + "\n");
            }
            fstream.read();
        } catch (Exception e) {

        }
        
        try {
            fstream.close();
        } catch(Exception e) {
        }
    }
    
    /** Creates new form OknoArchiwum */
    public OknoArchiwum() {
        otwarte = true;
        initComponents();
        
        addWindowListener(new WindowAdapter() {
            @Override
          public void windowClosing(WindowEvent e) {
            otwarte = false;
          }
        });
        poleArchiwum.setEditable(false);
        wczytaj();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        poleArchiwum = new javax.swing.JTextArea();

        //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        poleArchiwum.setColumns(20);
        poleArchiwum.setRows(5);
        jScrollPane1.setViewportView(poleArchiwum);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                        
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new OknoArchiwum().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea poleArchiwum;
    // End of variables declaration//GEN-END:variables
    
}
